package com.qf.fronted.service.impl;


import com.qf.fronted.domain.User;
import com.qf.fronted.mapper.UserMapper1;
import com.qf.fronted.service.UserService1;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.Date;

@Service
@Transactional
public class UserServiceImpl1 implements UserService1 {

    private UserMapper1 userMapper1;

    private UserServiceImpl1(UserMapper1 userMapper1) {
        this.userMapper1 = userMapper1;
    }

    @Override
    public Integer register(User user) {
        user.setStatus(1);
        user.setBalance(BigDecimal.valueOf(1000000));
        user.setRegisterDate(new Date());
        userMapper1.register(user);
        Integer pkValue = user.getId();
//        System.out.println("获取插入数据的主键"+pkValue);
        return pkValue;
    }

    @Override
    public Boolean checkPhoneOrUsername(String phoneOrUsername) {
        boolean isExists = false;
        String phone = userMapper1.checkPhoneOrUsername(phoneOrUsername);
        if (null != phone && !"".equals(phone.trim())){
            isExists = true;
        }
        return isExists;
    }

//    @Override
//    public User checkUsernameAndPassword(String username, String password) {
//        return userMapper1.checkUsernameAndPassword(username, password);
//    }
}
